package com.keshan.controller;

import com.keshan.utils.DateUtil;
import com.keshan.utils.Msg;
import com.keshan.pojo.SaveOurShip;
import com.keshan.pojo.SaveOurShipJson;
import com.keshan.service.SaveOurShipServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author keshan
 * @date 2022/10/21 - 19:36
 */
@CrossOrigin
@Controller
@RequestMapping("/saveourship")
public class SaveOurShipController {
    @Autowired
    SaveOurShipServices saveOurShipServices;

    @RequestMapping("/insertsaveourship")
    @ResponseBody
    public Msg insertBySelectiveToSaveOurShip(@RequestBody SaveOurShipJson saveOurShipJson){
        SaveOurShip saveOurShip =new SaveOurShip();
        saveOurShip.setAddress(saveOurShipJson.getAddress());
        saveOurShip.setCity(saveOurShipJson.getCity());
        saveOurShip.setDeviceType(saveOurShipJson.getDevice_type());
        saveOurShip.setImei(saveOurShipJson.getImei());
        saveOurShip.setLat(saveOurShipJson.getLat());
        saveOurShip.setLon(saveOurShipJson.getLon());
        saveOurShip.setTimeBegin(DateUtil.StringToDate(saveOurShipJson.getTime_begin_str()));
        saveOurShip.setType(saveOurShipJson.getType());
        int result = saveOurShipServices.insertBySelectiveSaveOurShip(saveOurShip);
        return Msg.success().add("result",result);
    }
}
